#ifndef __TCPSERVER_H__
#define __TCPSERVER_H__

#include "EventLoop.hpp"
#include "Acceptor.hpp"

using std::string;

namespace cdm{

class TCPServer{

public:
    TCPServer(uint16_t port,const string &ip = "0.0.0.0")
    :_acpt(port,ip),
    _loop(_acpt){

    }

    void setAllCallback(TCPCallback && cb1,
                        TCPCallback && cb2,
                        TCPCallback && cb3){
        _loop.setAllCallback(std::move(cb1),std::move(cb2),std::move(cb3));
    }

    void start(){
        _acpt.ready();
        _loop.loop();
    }

    void unLoop(){
        _loop.unloop();
    }

    ~TCPServer(){
        
    }

private:
    Acceptor    _acpt;
    EventLoop   _loop;
    

};

}//end of namespace

#endif


